package ThreadBasic.file;

import sun.misc.PostVMInitHook;

import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author yyh
 * @create 2020-11-03 16:48
 */
public class Z {
    public static void main(String[] args) throws Exception {
//        Scanner scanner = new Scanner(System.in);
//        String s = scanner.nextLine();
//        System.out.println(reverseArray(s,1,6));
//        char[] c = s.toCharArray();
//        String s1 = reverseArray(c, 1, 6);
//
//        System.out.println(s1);
//        String s1 = "yanyuhangyanyuhangyu";
//        String s2 = "yu";
//        System.out.println(getTimes(s1, s2));
//
//        String date1 = "1990/1/1"; // 开始“三天打鱼两天晒网”的日期
//        String date2 = "1990/1/10"; // 手动输入的日期
//        long day = geTo(date1, date2);// 传入值计算时间差
//        if (day % 5 == 0 || day % 5 == 4) {
//            System.out.println("今天是休息日，可以晒晒网");
//        } else {
//            System.out.println("今天要工作，打鱼了！");
//        }
//        int[] arr = new int[6];
//
//        System.out.println(Math.random() * 30);
//        for (int i = 0; i < arr.length; i++) {// [0,1) [0,30) [1,31)
//            arr[i] = (int) (Math.random() * 30) + 1;
//
//            for (int j = 0; j < i; j++) {
//                if (arr[i] == arr[j]) {
//                    i--;
//                    break;
//                }
//            }
//        }
//
//        for (int i = 0; i < arr.length; i++) {
//            System.out.println(arr[i]);
//        }

        System.out.print("请输入年：");
        Scanner s1 = new Scanner(System.in);
        int Year = s1.nextInt();
        System.out.print("请输入月：");
        Scanner s2 = new Scanner(System.in);
        int Mon = s2.nextInt();
        System.out.print("请输入日：");
        Scanner s3 = new Scanner(System.in);
        int Day = s3.nextInt();
        int sum = 0;

//        switch(Mon){
//            case 12:sum += 30;
//            case 11:sum += 31;
//            case 10:sum += 30;
//            case 9 :sum += 31;
//            case 8 :sum += 31;
//            case 7 :sum += 30;
//            case 6 :sum += 31;
//            case 5 :sum += 30;
//            case 4 :sum += 31;
//            case 3 :
//                if((Year % 4 == 0 && Year % 100 != 0) || (Year % 100 == 0 && Year % 400 == 0)){
//                    System.out.println("这一年是闰年！");
//                    sum += 29;
//                }
//                else{
//                    System.out.println("这一年是平年！");
//                    sum += 28;
//                }
//            case 2 :sum += 31;
//            case 1 :sum += Day;
//        }
        switch(Mon){
            case 12: sum+=30;
            case 11: sum+=31;
            case 10: sum+=30;
            case 9: sum+=31;
            case 8: sum+=31;
            case 7: sum+=30;
            case 6: sum+=31;
            case 5: sum+=30;
            case 4: sum+=31;
            case 3:
                if((Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0)){
                    System.out.println("这一年是闰年！");
                    sum += 29;
                }else{
                    System.out.println("这一年是平年！");
                    sum += 28;
                }
            case 2 : sum+=31;
            case 1: sum+=Day;
        }
        System.out.println(Year + "年" + Mon + "月" + Day + "日,是这一年的第：" + sum + "天");



    }

    public static String reverseArray(char[] c, int start, int end){
        for (int i = start, j = end ; i < j; i++,j--) {
            char temp = c[i];
            c[i] = c[j];
            c[j] = temp;
        }
        return new String(c);
    }

    public static String reverseArray(String str,int start, int end){
        String substring = str.substring(0, start);
        for (int i = end; i >= start ; i--) {
            char c = str.charAt(i);
            substring += c;
        }

        substring += str.substring(end+1);
        return substring;
    }

    public static int getTimes(String s1, String s2){
        int len ;
        int count = 0;

        while((len = s1.indexOf(s2)) != -1){
            count++;
            s1 = s1.substring(len+s2.length());
        }
        return count;
    }

    public static long geTo(String time1,String time2) throws Exception{
        long dayDistance = 0;
        SimpleDateFormat ft = new SimpleDateFormat("yyyy/MM/dd");
        Date parse = ft.parse(time1);
        Date parse2 = ft.parse(time2);
        dayDistance = parse2.getTime() - parse.getTime();
        dayDistance = dayDistance/1000/60/60/24 + 1;
        return dayDistance;
    }
}
